package com.zyg.apart.service.impl;

import java.util.Date;
import java.util.List;
import java.util.Map;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zyg.apart.mapper.LesseeMapper;
import com.zyg.apart.model.Lessee;
import com.zyg.apart.service.LesseeService;
import com.zyg.apart.util.Const;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


@Service
public class LesseeServiceImpl implements LesseeService {
	@Autowired
	private LesseeMapper lesseeMapper;


	@Override
	public PageInfo<Map<String, Object>> getAllLS(Integer currentPage) {
		PageHelper.startPage(currentPage, Const.pageSize);
		List<Map<String,Object>> list = lesseeMapper.getAllLS();
		PageInfo<Map<String, Object>> pageInfo = new PageInfo<>(list);
		return pageInfo;
	}

	@Override
	public Lessee getLSById(Integer id) {
		return lesseeMapper.getLSById(id);
	}

	@Override
	public int addLessee(Lessee lessee) {
		lessee.setL_create_time(new Date());
		return lesseeMapper.addLessee(lessee);
	}

	@Override
	public int editLessee(Lessee lessee) {
		return lesseeMapper.editLessee(lessee);
	}

	@Override
	public List<Lessee> getLSNames() {
		return lesseeMapper.getLSNames();
	}

	@Override
	public int delLesseeById(Integer id) {
		return lesseeMapper.delLesseeById(id);
	}
}
